package com.fs.ibox.util;

/**
 * <p>Title: ${file_name}</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2020</p>
 * <p>Company: www.baidudu.com</p>
 *
 * @author suke
 * @version 1.0
 * @date ${date}
 */

import com.fs.ibox.vo.ResponseData;
import com.fs.ibox.vo.ResultEnums;

/**
 * 带实体的统一返回
 * data 实体
 * <T>  实体类型
 *
 */
public class ResponseDataUtil {

    public static ResponseData buildOk(String msg) {
        return new ResponseData(ResultEnums.OK.getStatus(), msg);
    }

    public static <T> ResponseData buildOk(T data) {
        return new ResponseData<T>(ResultEnums.OK, data);
    }

    public static <T> ResponseData<T> buildOk(String msg,T data) {
        return new ResponseData(ResultEnums.OK.getStatus(), msg,data);
    }

    public static ResponseData buildOk(int status , String msg) {
        return new ResponseData(status, msg);
    }

    public static <T> ResponseData buildOk(int status, String msg, T data) {
        return new ResponseData<T>(status, msg, data);
    }

    public static ResponseData buildOk(ResultEnums resultEnums) {
        return new ResponseData(resultEnums);
    }

    public static <T> ResponseData buildCreate(T data) {
        return new ResponseData<T>(ResultEnums.CREATED, data);
    }

    public static <T> ResponseData buildDelete(T data) {
        return new ResponseData<T>(ResultEnums.DELETED, data);
    }

    public static <T> ResponseData buildUpdate(T data) {
        return new ResponseData<T>(ResultEnums.UPDATED, data);
    }

}